using System;
using Microsoft.Xna.Framework;

namespace SpriteAnimations.Graphics.Animations
{
    class RotateAnimation : SpriteAnimation
    {
        //
        // Fields
        //
        public TimeSpan animationLength;
        
        //
        // Constructors
        //
        public RotateAnimation(TimeSpan animationLength)
        {
            this.animationLength = animationLength;
        }

        //
        // Virtual Methods
        //
        public override void Animate(TimeSpan gameTime, SpriteParameters animatedParameters)
        {
            float elapsedPercentage = (float)((gameTime.TotalMilliseconds % animationLength.TotalMilliseconds) / animationLength.TotalMilliseconds);
            float rotation = (MathHelper.TwoPi * elapsedPercentage);

            animatedParameters.Rotation = rotation;
        }
    }
}
